0. Environment

Dependencies:

  1. Keras 2.0.6 (or higher version).
  2. Python 2.7-3.5
  3. Tensorflow or Theano or CNTK
  4. HDF5
  5. h5py
  6. graphviz
  7. pydot
  8. cuDNN (only for running on GPU)
  9. opencv

In this course, we are going to use Keras(A Python Deep Learning Library) to implement our deep learning model. It is compatible with Python 2.7-3.5. Keras uses Tensorflow, Theano, or CNTK as its backend engines, so only need to install one of them.

HDF5 and h5py libraries are used to save our model to disk. graphviz and pydot libraries are needed only when you want to plot model graphs to files (.png or .pdf).

In addition, if your computer has one or multiple NVIDIA graph cards, you may want to install cuDNN library to run Keras on GPU.


Next, I will show you how to setup the environment in Anaconda on MacOS. (For other Operating Systems, please modify the corresponding links or commands.)

# Open a terminal and type the following commands
# Step 1: Download Anaconda
> curl -O https://repo.continuum.io/archive/Anaconda3-4.4.0-MacOSX-x86_64.sh
# Step 2: Install Anaconda (Use all default settings)
> bash Anaconda3-4.4.0-MacOSX-x86_64.sh
# Step 3: Restart your terminal
# Step 4: Create a virtual environment. (so that it will not mess up the existing settings)
> conda create -n keras python=3.5
# Step 5: Install Tensorflow CPU version on Mac
> source activate keras
> pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.3.0-py3-none-any.whl
# If there is an error, please try it again.
# Step 6: Install Keras
> pip install keras
# Step 7: Install other Dependencies
> conda install HDF5
> conda install h5py
> pip install pydot
> pip install graphviz
> conda install -c https://conda.anaconda.org/menpo opencv3
# Step 8: Test
> python
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import plot_model
model = Sequential()
model.add(Dense(10, input_shape=(700, 1)))
model.summary()
plot_model(model, to_file='abc.pdf', show_shapes=True)
exit()
# If you get some error like: install graphviz, you can try this command:
> brew install graphviz